package leetcode.interview;

import java.util.HashMap;
import java.util.Map;

/**
 * ClassName: $04_PermutePalindrome
 * Description:
 * date: 2021-09-19 19:29
 *
 * @author liyifan
 */
public class $04_PermutePalindrome {
    public boolean canPermutePalindrome(String s) {
        HashMap<Character, Integer> map = new HashMap<>();
        for (Character c : s.toCharArray()) {
            map.put(c, map.getOrDefault(c, 0) + 1);
        }
        int x = 0;
        for (Map.Entry<Character, Integer> e:map.entrySet()) {
            if (e.getValue() % 2 == 0) {
                continue;
            } else {
                x++;
            }
        }
        return x <= 1;
    }
}
